import axios from "axios";

export default {
    namespaced: true, // 命名空间
    state: {
        userinfo: {
            name: '莫少松',
            age: 20
        }
    },
    mutations: {
        addAge(state, payload) {
            state.userinfo.age += payload
        },
        addcount(state) {
            state.userinfo.age++
        },
    },
    actions: {
        addAgeAsync({ commit }) {
            axios.get('../../assets/json/data.json').then(res => {
                //console.log(res.data.data.payload);
                commit('addAge', res.data.data.payload)
            })
        },
    },
    getters: {
        newuserinfo(state) {
            return {
                ...state.userinfo,
                age: state.userinfo.age * 2
            }
        }
    },
    modules: {

    }
}